package models

import "time"

type Url struct {
	ID          uint      `json:"id" gorm:"type:int(11);primary_key;AUTO_INCREMENT"`
	OriginalUrl string    `json:"original_url" gorm:"type:text;not null"`
	CustomCode  string    `json:"custom_code" gorm:"type:text;not null"`
	CreatedAt   time.Time `json:"created_at" gorm:"autoCreateTime;not null"`
	ExpiresAt   time.Time `json:"expires_at" gorm:"type:datetime(6)"`
	IsCustom    bool      `json:"is_custom" gorm:"type:boolean;not null"`
}

type UrlAddDto struct {
	OriginalURL string `json:"original_url" binding:"required,url"`
	CustomCode  string `json:"custom_code,omitempty" binding:"omitempty,min=4,max=10,alphanum"`
	Duration    *int   `json:"duration,omitempty" binding:"omitempty,min=0,max=10"`
}

type UrlAddVo struct {
	ShortURL  string `json:"short_url"`
	ExpiresAt string `json:"expires_at,omitempty"`
}
